package com.zpkj.portal.utils;

import org.apache.commons.lang.StringUtils;

public class SignUtil {
	
	/**
	 * 获取签名值 sign
	 * @param key
	 * @return
	 */
	public static String getSignValue(String key) {
		return HashUtils.TokenHash(key)+"";
	}
	
	/**
	 * 检验sign是否一致
	 */
	public static boolean checkSign(String signKey,String sign){
		if( StringUtils.isEmpty(signKey)||StringUtils.isEmpty(sign) ){
			return false;
		}
		if( sign.equals(getSignValue(signKey)) ){
			return true;
		}
		return false;
		//return true;
	}
	
//	public static void main(String args[]){
//		String key = "{\"header\":{\"macNo\":\"C8-1F-66-18-CA-07\",\"appVersion\":\"1\",\"requestType\":\"sendSmsCode\",\"loginUserId\":\"a3db9711de654c008764cd06e55c1bf7\"},\"body\":{\"loginUserId\":\"a3db9711de654c008764cd06e55c1bf7\"}}";
//		System.out.println(HashUtils.TokenHash(key));
//		Map<String,Object> map = SignUtil.getTXSign("123");
//		System.out.println(map);
//	}
}
